#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/4/3 18:51
# @Author : 闫峰
# @File    : t_jdwalmart_listing.py
from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database
from typing import List, Optional

zhcxkj_center_listing_comprehensive_db = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"),
                                                          "zhcxkj_center_listing_comprehensive")


class TJdwalmartListing:

    @staticmethod
    def get_listing_list_by_sku(sku_list: list) -> Optional[tuple]:

        # 构造SQL查询语句，用于从综合列表数据库中分批获取产品信息
        filter = """
            SELECT
        	source_id ,
        	source_name ,
        	item_id,
        	source_sku ,
        	sku
        FROM
        	zhcxkj_center_listing_comprehensive.t_jdwalmart_listing 
        WHERE
        	 sku IN %s
        	 	AND `status` IN ( 0, 1 ) 
        	AND is_deleted = 0 ;
            """
        data_list = zhcxkj_center_listing_comprehensive_db.fetch_all_tuple(filter, (sku_list,))
        if not len(sku_list):
            return None
        return data_list
